<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>发表新帖</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">

	<script type="text/javascript" src="<%=basePath%>ckeditor/ckeditor.js"></script>

<script type="text/javascript">
	/* ajax请求并返回图片的url 开始*/
	function loadXMLDoc(){
		var xmlhttp;
		if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		    {
		    document.getElementById("showChart").innerHTML=xmlhttp.responseText;
		    }
		  }
		xmlhttp.open("GET","<%=basePath%>jfreechart/HealthdataChartAction!LineChartView?userid=${temploginbean.userId}&charttype=BloodSugar",true);
		xmlhttp.send();
	}

	/* ajax请求并返回图片的url 结束*/

	/* 验证表单  开始*/
  	function CkeckForm(){
  		
  		var imagePattern =/^.*\.(jpg|gif|png|bmp)$/i;
  		var topicTitle=document.getElementById("topicTitle").value;
  		var topicClassify=document.getElementById("topicClassify").value;
  		var uploadImg=document.getElementById("up").value;
  		//var oEditor = CKEDITOR.instances.topicContent;
  		var topicContent=document.getElementById("topicContent").value;
  		
  		if(topicTitle==""){
  			document.getElementById("erromsg").innerHTML="帖子名称不能为空哦!";
  			document.getElementById("erromsg").style.color="red";
  			return false;
  		}
  		else if(topicClassify==""){
  			document.getElementById("erromsg").innerHTML="请选择帖子分类，方便其他用户能方便地看到您的帖子哦!";
  			document.getElementById("erromsg").style.color="red";
  			return false;
  		}
  		else if(uploadImg!= ""){
  			var flag=imagePattern.test(uploadImg);
  			if(!flag){
  				document.getElementById("erromsg").innerHTML="图片格式不正确!（必须为.jpg/.gif/.bmp/.png文件）";
  	  			document.getElementById("erromsg").style.color="red";
  	  			return false;
  			}
  		}
  		/* else if(oEditor.getData()==""){
  			document.getElementById("erromsg").innerHTML="至少写点什么吧！";
  			document.getElementById("erromsg").style.color="red";
  			return false;
  		} */
  		else if(topicContent==""){
  			document.getElementById("erromsg").innerHTML="至少写点什么哦!";
  			document.getElementById("erromsg").style.color="red";
  			return false;
  		}
  		else{
  			return true;
  		}
  	}
  	/* 验证表单  结束*/
</script>
<style type="text/css">
body{
	background-image:url('<%=basePath%>images/background4.jpg');
	background-repeat:no-repeat;
}
</style>
  </head>
  
  <body>
  
    <jsp:include page="../head.jsp"></jsp:include>  
    
	<div class="rightcase">
	
 	   <div style="min-height:700px;width:100%;margin:0 auto;background-color:#ffffff;"> 
 	   <div style="width:100%;height:30px;margin-left:10px;line-height:30px;">
				<a href="<%=basePath%>User_LoginAction"><img src="<%=basePath%>images/club_img2.png" width="15px" height="15px"></a>&nbsp;
				<!-- 判断是同龄圈还是医院圈 -->
					<s:if test="doctorinfo.doctorId!=null&&doctorinfo.doctorId!=0">
						<span style="font-size:10pt;font-family:微软雅黑;">>&nbsp;
							<a href="<%=basePath%>club_selectClubAction?clubid=${clubid}&page=${pagebean.currpage}&rows=${pagebean.rows}&docid=${doctorinfo.doctorId}" style="text-decoration:none;">
						<s:property value="club.clubName"/></a></span>
						<span style="font-size:10pt;font-family:微软雅黑;">>&nbsp;
							<a href="<%=basePath%>club_selectClubAction?clubid=${clubid}&orderflag=${pagebean.orderflag}&topicClassifyId=${pagebean.topicClassifyId}&page=${pagebean.currpage}&rows=${pagebean.rows}&docid=${doctorinfo.doctorId}" style="text-decoration:none;">
								<s:property value="doctorinfo.doctorName"/>圈
							</a>
						</span>
					</s:if>
					<s:else>
						<a href="<%=basePath%>club_selectClubAction?clubid=${clubid}&orderflag=${pagebean.orderflag}&topicClassifyId=${pagebean.topicClassifyId}&page=${pagebean.currpage}&rows=${pagebean.rows}"  style="text-decoration:none;">
							<s:property value="club.clubName"/>同龄圈
						</a>
					</s:else>	
		</div>
 	   
 	   <form id="topicForm" action="<%=basePath%>club_addTopicAction" method="post" enctype ="multipart/form-data">
 	   	 <!-- 隐藏表单域 -->
 	   	 <input type="text" name="topic.clubCategoryId" value="<s:property value='club.clubCategoryId'/>" style="border:0;display:none"/>
 	   	 <input type="hidden" name="topic.topicAuthorId" value="<s:property value='#session.temploginbean.userId'/>">
 	   	<!-- 保存当前的页码和每页显示大小设置 -->
		<input type="hidden" name="pagebean.rows" value="<s:property value='pagebean.rows'/>">
		<!-- 分类信息和排序信息 -->
		<input type="hidden" name="pagebean.topicClassifyId" value="<s:property value='pagebean.topicClassifyId'/>">
		<input type="hidden" name="pagebean.orderflag" value="<s:property value='pagebean.orderflag'/>">
		<!-- 若为医院圈 -->
		<s:if test="doctorinfo.doctorId!=null&&doctorinfo.doctorId>0">
			<input type="hidden" name="doctorinfo.doctorId" value="<s:property value='doctorinfo.doctorId'/>">
		</s:if>
		
 	   	 <div style="width:100px;height:50px;margin-left:20px;">
				<span style="font-size:12pt;font-family:微软雅黑;">发表新帖</span>
		 </div>
 	   
 	   	  <div style="min-height:95%;width:75%;padding:20px;margin:0 auto;border:1px solid #E0FFFF; ">
		
			<div style="width:100%;height:50px;margin:10px auto;">
				主题：<input type="text" id="topicTitle" name="topic.topicTitle" style="height:30px;width:90%;"/>
			</div>
			
			<div style="width:100%;height:40px;margin:10px auto;">
				分类：<select id="topicClassify" name="topic.topicClassifyId" style="height:30px;width:15%;">
						<option value="">选择主题分类</option>
						<s:iterator value="topicClassifyList" var="curQueryForm" status="attr">
							<option	value=<s:property value="topicClassifyId"/>>							
								<s:property value="topicClassifyName" />
							</option>
						</s:iterator>
					</select>
			</div>
			
			<div style="width:100%;margin:0px auto;">
				 内容：<br/><br/>
				 <textarea id="topicContent" name="topic.topicContent" style="width:98%;height:400px"></textarea>
				 <!-- <textarea id="topicContent" name="topic.topicContent" class="ckeditor"></textarea>	 -->		 	
			</div>
			<script language="javascript" type="text/javascript">
				/* function PreviewImg(imgFile)
				{
				    var newPreview = document.getElementById("newPreview");
				    alert("imgFile.value:"+imgFile.value);
				    newPreview.src = imgFile.value;
				    newPreview.style.width = "180px";
				    newPreview.style.height = "160px";
				} */
			</script>
			
			<div style="width:100%;height:30px;margin:10px auto;">
				上传图片：
				<INPUT type="file" id="up" name="upload" multiple onchange="javascript:document.getElementById('showImgPreview').style.display='inline'" />
				<input type='button' value='取消' 
				onclick="javascript:document.getElementById('up').value='';document.getElementById('ImgPr').src='';document.getElementById('showImgPreview').style.display='none'"/>
			</div>
			<!-- 图片预览区域 -->
			<script>
				/* $(document).ready(function(){  
		            $("#FileUpload1").PreviewImage({ ImageClientId: "imgPre", MaxWidth: "300", MaxHeight: "200" });  
		        });  */
		        $(function () {
		            $("#up").uploadPreview({ Img: "ImgPr", MaxWidth: 300, MaxHeight: 300 });
		        });
		    </script>
		    <div id="showImgPreview" style="display:none"><img id="ImgPr" width="120" height="120" /></div>
			<!-- <div id="newPreview"></div> -->
			<!-- <div id="previewImg" style="width:100%;height:100px;margin:10px auto;display:none;">
				<img id="imgsrc" alt="图1" src="">
			</div> -->
			<div style="width:100%;height:30px;margin:0px auto;">
				<div style="width:10%;height:100%;float:left;">
					<input type="image" src="<%=basePath%>images/addTopic.png" style="cursor: pointer;" onclick="return CkeckForm();" border=0>
				</div>
				<div style="width:88%;height:100%;float:right;text-align:left;">
					<span id="erromsg"></span>
				</div>
			</div>
		</div>
		</form>
		</div>
    <%@ include file="../foot.jsp"%>
  </div>
  </body>
</html>
